<?php
import("ORG.Util.QPage"); 
import("ORG.Util.Function");

class IndexAction extends CommonAction {
	
	public function _initialize(){
		parent::_initialize();
	}
	//construct 
	public function __construct(){
		parent::__construct(); //must have
		$user_name          =   $_SESSION['user_name'];
		$this->assign("username",$user_name);
		$this->assign("web_title","后台管理");
	}
	
    public function index(){
    	$this->display();
	}
	
	public  function  findParentName($cat_id){
		$CatModel	=	new Model("CourseCategory");
    	$catList	=	$CatModel->field("id,name,parent_id")->select();
    	$catInfo	= 	$CatModel->field("id,name,parent_id")->where("id = '{$cat_id}'")->find();
    	$parent_id	= 	$catInfo['parent_id'];
    	$cat_name	=	$catInfo['name'];
    	// 判断parent_id是否为0
    	if($parent_id == 0){
    		$cat_name = $catInfo ['name'];
    		return true;
    	}
    	else{
	    	while( $parent_id !=0 ){
		        $catInfo 		= 	$CatModel->field("id,name,parent_id")->where("id = '{$parent_id}'")->find();
		        $cat_name		=	$catInfo['name'] . " > " . $cat_name;
		        $parent_id 		= 	$catInfo['parent_id'];
			}
    	}	   		
		return $cat_name;
	}
	
	public function top(){		
		$this->display();
	}

	public  function left(){
		$this->display();
	}
	
	public function right(){		
		$this->display();
	}
	
	public function header(){		
		$this->display();
	}
}
